# Maintainer: Felix Yan <felixonmars@archlinux.org>
# Contributor: Arch Haskell Team <arch-haskell@haskell.org>

_hkgname=yesod-core
pkgname=haskell-yesod-core
pkgver=1.6.24.5
pkgrel=14
pkgdesc="Creation of type-safe, RESTful web applications."
url="http://www.yesodweb.com/"
license=("MIT")
arch=('loong64' 'x86_64')
depends=('ghc-libs' 'haskell-aeson' 'haskell-attoparsec-aeson' 'haskell-auto-update'
         'haskell-blaze-html' 'haskell-blaze-markup' 'haskell-case-insensitive' 'haskell-cereal'
         'haskell-clientsession' 'haskell-conduit' 'haskell-conduit-extra' 'haskell-cookie'
         'haskell-entropy' 'haskell-fast-logger' 'haskell-http-types' 'haskell-memory'
         'haskell-monad-logger' 'haskell-old-locale' 'haskell-path-pieces' 'haskell-primitive'
         'haskell-random' 'haskell-resourcet' 'haskell-shakespeare' 'haskell-unix-compat'
         'haskell-unliftio' 'haskell-unordered-containers' 'haskell-vector' 'haskell-wai'
         'haskell-wai-extra' 'haskell-wai-logger' 'haskell-warp' 'haskell-word8')
makedepends=('ghc' 'haskell-hunit' 'haskell-async' 'haskell-hspec'
             'haskell-hspec-expectations' 'haskell-network' 'haskell-streaming-commons')
source=("https://hackage.haskell.org/packages/archive/${_hkgname}/${pkgver}/${_hkgname}-${pkgver}.tar.gz")
sha512sums=('5c4042a609f6ebf46017ab2e50f6fa92b02005b18d32c86a1bf585ac308001fd14e96a956d062e30798d0126424d22934259d56cf9888c98e52199bca36b3031')

build() {
    cd $_hkgname-$pkgver
    
    runhaskell Setup configure -O --enable-shared --enable-executable-dynamic --disable-library-vanilla \
        --prefix=/usr --docdir=/usr/share/doc/$pkgname --datasubdir=$pkgname --enable-tests \
        --dynlibdir=/usr/lib --libsubdir=\$compiler/site-local/\$pkgid --ghc-option=-fllvm
    runhaskell Setup build $MAKEFLAGS
    runhaskell Setup register --gen-script
    runhaskell Setup unregister --gen-script
    sed -i -r -e "s|ghc-pkg.*update[^ ]* |&'--force' |" register.sh
    sed -i -r -e "s|ghc-pkg.*unregister[^ ]* |&'--force' |" unregister.sh
}

check() {
    cd $_hkgname-$pkgver
    runhaskell Setup test --show-details=direct
}

package() {
    cd $_hkgname-$pkgver
    
    install -D -m744 register.sh "$pkgdir"/usr/share/haskell/register/$pkgname.sh
    install -D -m744 unregister.sh "$pkgdir"/usr/share/haskell/unregister/$pkgname.sh
    runhaskell Setup copy --destdir="$pkgdir"
    install -D -m644 LICENSE "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
    rm -f "$pkgdir"/usr/share/doc/$pkgname/LICENSE
}
